<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
        <title>测试管理</title>
        <include file='Layout:ins_css' />
        <style type="text/css">
            #addBtn {
                float: right;
                margin: -7px -6px 9px;
            }
        </style>
    </head>
    <body>
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>测试管理</h5>
                            <button class="btn btn-primary" id="addBtn">新增</button>
                        </div>
                        <div class="row s-row">
                            <div class="col-sm-12">
                                <div class="price-div">
                                    <form class="form-horizontal">
                                        <div class="form-group cyf-form-group">
                                            <div class="col-sm-4" style="margin-top: 10px; margin-bottom: 10px">
                                                <label style="float: left" class="col-sm-4 control-label cvbnm">教学方案: </label>
                                                <select class="form-control col-sm-" id="teach_method_id" name="teach_method_id" style="min-height: 35px">
                                                    <option value="0">全部</option>
                                                    <volist name="teach_method_info" id="vo">
                                                        <option value="{$vo.id}">{$vo.me_name}</option>
                                                    </volist>
                                                </select>
                                            </div>
                                            <div class="col-sm-4" style="margin-top: 10px; margin-bottom: 10px">
                                                <label style="float: left; margin-right: 13px;" class="col-sm-4 control-label cvbnm">章: </label>
                                                <select class="form-control col-sm-" id="chapter_id" name="chapter_id" style="min-height: 35px">
                                                    <option value="0">全部</option>
                                                    <volist name="chapter_info" id="vo">
                                                        <option value="{$vo.cha_id}" pid="{$vo.tme_id}"  style="display: none;">{$vo.cha_name}</option>
                                                    </volist>
                                                </select>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                        <div class="ibox-content">
                            <table class="table table-striped table-bordered table-hover dataTables-example" id="RuleTable">
                                <thead>
                                <tr>
                                    <th width="12.5%">规则编号</th>
                                    <th width="12.5%">所属章</th>
                                    <th width="12.5%">知识点</th>
                                    <th width="12.5%">题型</th>
                                    <th width="12.5%">难度</th>
                                    <th width="12.5%">数量</th>
                                    <th width="12.5%">分值</th>
                                    <th width="12.5%">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- Modal 新增单个专业-->
        <div class="modal fade" id="Modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">新增专业</h4>
                    </div>
                    <div class="modal-body">
                        <form class="form-horizontal" id="form_add">
                            <div class="form-group">
                                <label class="col-sm-3 control-label ">教学方案</label>
                                <div class="col-sm-7">
                                    <input type="text" id="teach_method_input" name="teach_method_input" class="form-control removeData">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">章</label>
                                <div class="col-sm-7">
                                    <input type="text" id="chapter_input" name="chapter_input" class="form-control removeData">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label cvbnm nationality">题型</label>
                                <select class="form-control poiu" id="select_exeType" name="select_exeType">
                                    <option value="0">请选择</option>
                                    <volist name="par_college" id="par_college">
                                        <option value="{$par_college.sch_id}">{$par_college.sch_name}</option>
                                    </volist>
                                </select>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label cvbnm nationality">难度</label>
                                <select class="form-control poiu" id="select_diff" name="select_diff">
                                    <option value="0">请选择</option>
                                    <volist name="par_department" id="par_department">
                                        <option value="{$par_department.dept_id}" pid="{$par_department.sch_id}" class="p_department_id" style="display: none;">{$par_department.dept_name}</option>
                                    </volist>
                                </select>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label cvbnm nationality">知识点</label>
                                <select class="form-control poiu" id="select_point" name="select_point">
                                    <option value="0">请选择</option>
                                    <volist name="par_department" id="par_department">
                                        <option value="{$par_department.dept_id}" pid="{$par_department.sch_id}" class="p_department_id" style="display: none;">{$par_department.dept_name}</option>
                                    </volist>
                                </select>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label ">题目数量</label>
                                <div class="col-sm-7">
                                    <input type="text" id="teach_method_input" name="teach_method_input" class="form-control removeData">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">分值</label>
                                <div class="col-sm-7">
                                    <input type="text" id="chapter_input" name="chapter_input" class="form-control removeData">
                                </div>
                            </div>
                            
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-primary" id="add_btn">保存</button>
                    </div>
                </div>
            </div>
        </div>
        <include file='Layout:ins_js' />
        <script type="text/javascript">
            $(document).ready(function () {
                check_index();
                sTable = $("#RuleTable").DataTable({
                    "fnServerParams": function (aoData) {
                        aoData.push({
                            'name': 'chapter_id',
                            'value': $('select#chapter_id option:selected').val(),
                        });
                    },
                    "order": [[0, "asc"]],
                    //              "aaSorting": [
                    //                  [0, "asc"]
                    //              ],
                    "bAutoWidth": false,
                    "oLanguage": {
                        "sLengthMenu": "每页 _MENU_ ",
                        "sProcessing": "处理中...",
                        "sZeroRecords": "没有匹配结果",
                        "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
                        "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
                        "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
                        "sInfoPostFix": "",
                        "sSearch": "搜索:",
                        "sUrl": "",
                        "sEmptyTable": "表中数据为空",
                        "sLoadingRecords": "载入中...",
                        "sInfoThousands": ",",
                        "oPaginate": {
                            "sFirst": "首页",
                            "sPrevious": "上页",
                            "sNext": "下页",
                            "sLast": "末页"
                        },
                        "oAria": {
                            "sSortAscending": ": 以升序排列此列",
                            "sSortDescending": ": 以降序排列此列"
                        }
                    },
                    "sAjaxSource": "__URL__/textRule_ShowDatatables", //调用php后台接口方法地址
                    "aoColumns": [{
                        'data'  : 'ru_id'
                    },{
                        'data': 'cha_name'
                    },{
                        'data': 'knowledge_content'
                    },{
                        'data': 'ru_type'
                    },{
                        'data': 'ru_difficulty'
                    },{
                        'data': 'ru_num'
                    }, {
                        'data': 'ru_score'
                    },  {
                        "data": null,
                        orderable: false,
                        render: function (data, type, row, meta) {
                            return '<a type="button" class="btn btn-success" href="#" onclick=editFromID(this) >编辑</a>|<a type="button" class="btn btn-danger" href="#" onclick=delFromID(this) >删除</a>'
                        }
                    }]
                });
                //select2
                $("#select_exeType").select2({
                    width: '300px',
                    dropdownParent: $("#Modal"),

                });
                $("#select_diff").select2({
                    width: '300px',
                    dropdownParent: $("#Modal"),

                });
                $("#select_point").select2({
                    width: '300px',
                    dropdownParent: $("#Modal"),

                });
                
                
            });

            $("select#teach_method_id").change(function() {
                //console.log( $('select#college_id option:selected').val());
                var p_id = $("#teach_method_id").val();
                $("#chapter_id option").hide();
                $('#chapter_id').val('0');
                $('option[pid=' + p_id + ']').show();
            });
            $("select#chapter_id").change(function(){
                sTable.ajax.reload();
            });
            $('#addBtn').on('click',function(){
            	$('#Modal').modal();
            });
        </script>
    </body>
</html>